#define  _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    int dp[100005];
    int a[100005];
    for (int i = 0; i < n; i++)
        cin >> a[i];

    for (int i = 2; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + a[i - 1], dp[i - 2] + a[i - 2]);
    }
    cout << dp[n];
    return 0;
}